<?php

class DbUtil
{
    public function __construct(){
        $this->conn = new mysqli('localhost','root','root','php');
       
         if($this->conn->connect_errno!=0){
             echo "连接数据库失败";
             exit;
         }else{
             $this->conn->query("SET NAMES UTF8");
         }
         
    }
    
    public function query($sql){
        echo $sql;
       return  $this->conn->query($sql);
        
   }
    
}

$db = new DbUtil();

$str = "select * from user";

$res = $db->query($str);

$row = $res->fetch_array(MYSQLI_ASSOC);


while($row = $res->fetch_array(MYSQLI_ASSOC)){
  //  print_r($row);
   $rows[] = $row;
}

foreach ($rows as $re){
    echo $re['username'].':'.$re['password'];
}

?>

<?php 
$x = 75;
$y = '25.9'; 

function addition()
{
    global $y;
    echo $y;
$GLOBALS['z'] = $GLOBALS['x'] + $y;
}

addition();
echo $z;
$GLOBALS['j'] = 'aaaaaaaa';

echo intval($y) - 3;
echo $j;

echo date('Y-m-d',time());

echo mb_substr("nihaozhisheiwodejia", 0,5);
?>


